'''
    HttpResponse: 返回Http
    JsonResponse: 返回Json
    FileResponse: 返回file
'''
from django.http import HttpResponse, JsonResponse, FileResponse


def testResponse_http(request):
    print('request method: ', request.method)
    print('request META: ', request.META) # META 是客户端信息
    print('request COOKIES: ', request.COOKIES)
    print('request QueryDict(GET): ', request.GET) # GET 请求参数

    # content: 返回的内容
    # status: 返回的状态码
    return HttpResponse(content='OK', status=200)


def testResponse_json(request):
    print('request method: ', request.method)
    print('request META: ', request.META)
    print('request COOKIES: ', request.COOKIES)
    print('request QueryDict(GET): ', request.GET)

    # content: 返回的内容
    # status: 返回的状态码
    # safe: 为false时，将不会检查 python 对象，为true时会只能装换 dict 对象
    m = {
        "message": "Hello Django Response"
    }
    return JsonResponse(data=m, safe=False, status=200)
